/*
 Navicat Premium Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 80026
 Source Host           : localhost:3306
 Source Schema         : smartpark

 Target Server Type    : MySQL
 Target Server Version : 80026
 File Encoding         : 65001

 Date: 11/03/2025 21:49:13
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for announcement
-- ----------------------------
DROP TABLE IF EXISTS `announcement`;
CREATE TABLE `announcement` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `title` varchar(100) NOT NULL COMMENT '公告标题',
  `content` text COMMENT '公告内容',
  `category_id` int DEFAULT NULL COMMENT '公告分类ID',
  `publisher_id` int NOT NULL COMMENT '发布者ID',
  `publisher_name` varchar(50) DEFAULT NULL COMMENT '发布者名称',
  `priority` tinyint DEFAULT '0' COMMENT '优先级（0-低，1-中，2-高）',
  `start_time` datetime DEFAULT NULL COMMENT '生效开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '生效结束时间',
  `is_top` tinyint DEFAULT '0' COMMENT '是否置顶（0-否，1-是）',
  `status` tinyint DEFAULT '1' COMMENT '状态（0-草稿，1-已发布，2-已下线）',
  `read_count` int DEFAULT '0' COMMENT '阅读次数',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`),
  KEY `publisher_id` (`publisher_id`),
  CONSTRAINT `announcement_ibfk_1` FOREIGN KEY (`publisher_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='公告表';

-- ----------------------------
-- Records of announcement
-- ----------------------------
BEGIN;
INSERT INTO `announcement` (`id`, `title`, `content`, `category_id`, `publisher_id`, `publisher_name`, `priority`, `start_time`, `end_time`, `is_top`, `status`, `read_count`, `created_at`, `updated_at`, `deleted`) VALUES (1, '测试系统通知', '测试11111111111', 1, 7, NULL, 0, '2025-03-13 00:00:00', '2025-03-20 00:00:00', 1, 1, 0, '2025-03-11 13:11:42', '2025-03-11 13:14:16', 1);
INSERT INTO `announcement` (`id`, `title`, `content`, `category_id`, `publisher_id`, `publisher_name`, `priority`, `start_time`, `end_time`, `is_top`, `status`, `read_count`, `created_at`, `updated_at`, `deleted`) VALUES (2, '网站维护', '网站将会在半夜进行维护', 2, 7, NULL, 0, '2025-03-11 00:00:00', '2025-03-20 00:00:00', 0, 1, 1, '2025-03-11 13:13:12', '2025-03-11 13:13:12', 0);
INSERT INTO `announcement` (`id`, `title`, `content`, `category_id`, `publisher_id`, `publisher_name`, `priority`, `start_time`, `end_time`, `is_top`, `status`, `read_count`, `created_at`, `updated_at`, `deleted`) VALUES (3, '网站上线了', '欢迎大家使用停车场管理系统', 3, 7, NULL, 0, '2025-03-11 00:00:00', '2025-03-12 00:00:00', 0, 1, 9, '2025-03-11 13:13:36', '2025-03-11 13:13:36', 0);
COMMIT;

-- ----------------------------
-- Table structure for announcement_category
-- ----------------------------
DROP TABLE IF EXISTS `announcement_category`;
CREATE TABLE `announcement_category` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(50) NOT NULL COMMENT '分类名称',
  `sort_order` int DEFAULT '0' COMMENT '排序序号',
  `status` tinyint DEFAULT '1' COMMENT '状态（0-禁用，1-启用）',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  `description` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='公告分类表';

-- ----------------------------
-- Records of announcement_category
-- ----------------------------
BEGIN;
INSERT INTO `announcement_category` (`id`, `name`, `sort_order`, `status`, `created_at`, `updated_at`, `deleted`, `description`) VALUES (1, '系统通知', 1, 1, '2025-03-10 19:50:49', '2025-03-10 19:50:49', 0, NULL);
INSERT INTO `announcement_category` (`id`, `name`, `sort_order`, `status`, `created_at`, `updated_at`, `deleted`, `description`) VALUES (2, '维护公告', 2, 1, '2025-03-10 19:50:49', '2025-03-10 19:50:49', 0, NULL);
INSERT INTO `announcement_category` (`id`, `name`, `sort_order`, `status`, `created_at`, `updated_at`, `deleted`, `description`) VALUES (3, '活动通知', 3, 1, '2025-03-10 19:50:49', '2025-03-10 19:50:49', 0, NULL);
COMMIT;

-- ----------------------------
-- Table structure for announcement_read
-- ----------------------------
DROP TABLE IF EXISTS `announcement_read`;
CREATE TABLE `announcement_read` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` int NOT NULL COMMENT '用户ID',
  `announcement_id` int NOT NULL COMMENT '公告ID',
  `is_read` tinyint DEFAULT '1' COMMENT '是否已读（0-未读，1-已读）',
  `read_time` datetime DEFAULT NULL COMMENT '阅读时间',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`),
  KEY `idx_user_announcement` (`user_id`,`announcement_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='公告阅读记录表';

-- ----------------------------
-- Records of announcement_read
-- ----------------------------
BEGIN;
INSERT INTO `announcement_read` (`id`, `user_id`, `announcement_id`, `is_read`, `read_time`, `created_at`, `updated_at`, `deleted`) VALUES (1, 8, 3, 1, '2025-03-11 13:36:28', '2025-03-11 13:36:28', '2025-03-11 13:36:28', 0);
INSERT INTO `announcement_read` (`id`, `user_id`, `announcement_id`, `is_read`, `read_time`, `created_at`, `updated_at`, `deleted`) VALUES (2, 8, 2, 1, '2025-03-11 13:39:35', '2025-03-11 13:39:35', '2025-03-11 13:39:35', 0);
COMMIT;

-- ----------------------------
-- Table structure for fee_standard
-- ----------------------------
DROP TABLE IF EXISTS `fee_standard`;
CREATE TABLE `fee_standard` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(100) NOT NULL COMMENT '标准名称',
  `space_type` tinyint DEFAULT '0' COMMENT '车位类型（0-普通，1-固定，2-访客）',
  `fee_type` tinyint DEFAULT '0' COMMENT '收费类型（0-小时，1-天，2-月，3-年）',
  `fee_amount` decimal(10,2) NOT NULL COMMENT '费用金额',
  `free_minutes` int DEFAULT '0' COMMENT '免费时长（分钟）',
  `day_cap` decimal(10,2) DEFAULT '0.00' COMMENT '每日封顶金额',
  `start_time` datetime NOT NULL COMMENT '生效开始时间',
  `end_time` datetime NOT NULL COMMENT '生效结束时间',
  `status` tinyint DEFAULT '1' COMMENT '状态（0-禁用，1-启用）',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='收费标准表';

-- ----------------------------
-- Records of fee_standard
-- ----------------------------
BEGIN;
INSERT INTO `fee_standard` (`id`, `name`, `space_type`, `fee_type`, `fee_amount`, `free_minutes`, `day_cap`, `start_time`, `end_time`, `status`, `created_at`, `updated_at`, `deleted`) VALUES (1, '普通时段收费', 0, 0, 5.00, 0, 50.00, '2023-01-01 00:00:00', '2030-12-31 23:59:59', 1, '2025-03-10 19:50:49', '2025-03-10 19:50:49', 0);
INSERT INTO `fee_standard` (`id`, `name`, `space_type`, `fee_type`, `fee_amount`, `free_minutes`, `day_cap`, `start_time`, `end_time`, `status`, `created_at`, `updated_at`, `deleted`) VALUES (2, '固定车位月租', 1, 2, 300.00, 0, 0.00, '2023-01-01 00:00:00', '2030-12-31 23:59:59', 1, '2025-03-10 19:50:49', '2025-03-10 19:50:49', 0);
INSERT INTO `fee_standard` (`id`, `name`, `space_type`, `fee_type`, `fee_amount`, `free_minutes`, `day_cap`, `start_time`, `end_time`, `status`, `created_at`, `updated_at`, `deleted`) VALUES (3, '访客临时停车', 2, 0, 8.00, 30, 80.00, '2023-01-01 00:00:00', '2030-12-31 23:59:59', 1, '2025-03-10 19:50:49', '2025-03-10 19:50:49', 0);
COMMIT;

-- ----------------------------
-- Table structure for parking_lot
-- ----------------------------
DROP TABLE IF EXISTS `parking_lot`;
CREATE TABLE `parking_lot` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(100) NOT NULL COMMENT '停车场名称',
  `address` varchar(255) DEFAULT NULL COMMENT '地址',
  `total_spaces` int DEFAULT '0' COMMENT '总车位数',
  `available_spaces` int DEFAULT '0' COMMENT '可用车位数',
  `open_time` time DEFAULT NULL COMMENT '开放时间',
  `close_time` time DEFAULT NULL COMMENT '关闭时间',
  `contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
  `status` tinyint DEFAULT '1' COMMENT '状态（0-关闭，1-开放）',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='停车场表';

-- ----------------------------
-- Records of parking_lot
-- ----------------------------
BEGIN;
INSERT INTO `parking_lot` (`id`, `name`, `address`, `total_spaces`, `available_spaces`, `open_time`, `close_time`, `contact_phone`, `status`, `created_at`, `updated_at`, `deleted`) VALUES (7, '智慧小区地下停车场', '智慧小区地下一层', 100, 6, '00:00:00', '23:59:00', '13800138000', 1, '2025-03-11 15:01:38', '2025-03-11 15:01:38', 0);
COMMIT;

-- ----------------------------
-- Table structure for parking_record
-- ----------------------------
DROP TABLE IF EXISTS `parking_record`;
CREATE TABLE `parking_record` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `vehicle_id` int NOT NULL COMMENT '车辆ID',
  `parking_space_id` int DEFAULT NULL COMMENT '车位ID',
  `entry_time` datetime NOT NULL COMMENT '入场时间',
  `exit_time` datetime DEFAULT NULL COMMENT '出场时间（null表示未出场）',
  `parking_fee` decimal(10,2) DEFAULT '0.00' COMMENT '停车费用',
  `is_paid` tinyint DEFAULT '0' COMMENT '是否已支付（0-未支付，1-已支付）',
  `payment_id` int DEFAULT NULL COMMENT '支付记录ID',
  `status` tinyint DEFAULT '0' COMMENT '状态（0-进行中，1-已完成，2-异常）',
  `remark` text COMMENT '备注信息',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`),
  KEY `vehicle_id` (`vehicle_id`),
  KEY `parking_space_id` (`parking_space_id`),
  CONSTRAINT `parking_record_ibfk_1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`id`) ON DELETE CASCADE,
  CONSTRAINT `parking_record_ibfk_2` FOREIGN KEY (`parking_space_id`) REFERENCES `parking_space` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='停车记录表';

-- ----------------------------
-- Records of parking_record
-- ----------------------------
BEGIN;
INSERT INTO `parking_record` (`id`, `vehicle_id`, `parking_space_id`, `entry_time`, `exit_time`, `parking_fee`, `is_paid`, `payment_id`, `status`, `remark`, `created_at`, `updated_at`, `deleted`) VALUES (8, 1, 93, '2025-03-11 21:04:31', '2025-03-11 21:04:49', 10.00, 1, 33, 1, NULL, '2025-03-11 21:04:31', '2025-03-11 21:04:31', 0);
INSERT INTO `parking_record` (`id`, `vehicle_id`, `parking_space_id`, `entry_time`, `exit_time`, `parking_fee`, `is_paid`, `payment_id`, `status`, `remark`, `created_at`, `updated_at`, `deleted`) VALUES (9, 1, 94, '2025-03-11 21:19:59', '2025-03-11 21:20:06', 10.00, 1, 35, 1, NULL, '2025-03-11 21:19:59', '2025-03-11 21:19:59', 0);
INSERT INTO `parking_record` (`id`, `vehicle_id`, `parking_space_id`, `entry_time`, `exit_time`, `parking_fee`, `is_paid`, `payment_id`, `status`, `remark`, `created_at`, `updated_at`, `deleted`) VALUES (10, 1, 94, '2025-03-11 21:21:17', '2025-03-11 21:21:35', 10.00, 1, 37, 1, NULL, '2025-03-11 21:21:17', '2025-03-11 21:21:17', 0);
COMMIT;

-- ----------------------------
-- Table structure for parking_space
-- ----------------------------
DROP TABLE IF EXISTS `parking_space`;
CREATE TABLE `parking_space` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `parking_lot_id` int NOT NULL COMMENT '停车场ID',
  `space_number` varchar(20) NOT NULL COMMENT '车位编号',
  `space_type` tinyint DEFAULT '0' COMMENT '车位类型（0-普通，1-固定，2-访客）',
  `area` varchar(50) DEFAULT NULL COMMENT '所在区域',
  `floor` varchar(20) DEFAULT NULL COMMENT '所在楼层',
  `status` tinyint DEFAULT '0' COMMENT '状态（0-空闲，1-占用，2-维护，3-预约，4-禁用）',
  `position_x` decimal(10,6) DEFAULT NULL COMMENT '地图X坐标',
  `position_y` decimal(10,6) DEFAULT NULL COMMENT '地图Y坐标',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`),
  KEY `parking_lot_id` (`parking_lot_id`),
  CONSTRAINT `parking_space_ibfk_1` FOREIGN KEY (`parking_lot_id`) REFERENCES `parking_lot` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车位表';

-- ----------------------------
-- Records of parking_space
-- ----------------------------
BEGIN;
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (93, 7, 'A-001', 0, 'A', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 15:02:00', 0);
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (94, 7, 'A-002', 0, 'A', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 21:04:00', 0);
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (95, 7, 'A-003', 0, 'A', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 15:02:00', 0);
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (96, 7, 'B-001', 1, 'B', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 15:02:00', 0);
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (97, 7, 'B-002', 1, 'B', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 15:02:00', 0);
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (98, 7, 'C-001', 2, 'C', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 15:02:00', 0);
INSERT INTO `parking_space` (`id`, `parking_lot_id`, `space_number`, `space_type`, `area`, `floor`, `status`, `position_x`, `position_y`, `created_at`, `updated_at`, `deleted`) VALUES (99, 7, 'C-002', 2, 'C', 'B1', 0, NULL, NULL, '2025-03-11 15:02:00', '2025-03-11 15:02:00', 0);
COMMIT;

-- ----------------------------
-- Table structure for payment
-- ----------------------------
DROP TABLE IF EXISTS `payment`;
CREATE TABLE `payment` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` int NOT NULL COMMENT '用户ID',
  `order_number` varchar(50) NOT NULL COMMENT '订单编号',
  `payment_type` tinyint NOT NULL COMMENT '支付类型（0-停车费，1-预约费）',
  `payment_method` tinyint DEFAULT NULL COMMENT '支付方式（0-支付宝，1-微信，2-银行卡，3-余额）',
  `amount` decimal(10,2) NOT NULL COMMENT '支付金额',
  `status` tinyint DEFAULT '0' COMMENT '状态（0-待支付，1-已支付，2-已退款，3-已取消）',
  `transaction_id` varchar(100) DEFAULT NULL COMMENT '交易流水号',
  `pay_time` datetime DEFAULT NULL COMMENT '支付时间',
  `remark` text COMMENT '备注信息',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  `record_id` bigint DEFAULT NULL COMMENT '关联记录ID（停车记录ID或预约ID）',
  PRIMARY KEY (`id`),
  UNIQUE KEY `order_number` (`order_number`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='支付记录表';

-- ----------------------------
-- Records of payment
-- ----------------------------
BEGIN;
INSERT INTO `payment` (`id`, `user_id`, `order_number`, `payment_type`, `payment_method`, `amount`, `status`, `transaction_id`, `pay_time`, `remark`, `created_at`, `updated_at`, `deleted`, `record_id`) VALUES (32, 8, '1741698262951801b1cea', 1, 3, 10.00, 1, 'TX1741698265411729', '2025-03-11 21:04:25', '预约费支付-A-001', '2025-03-11 21:04:23', '2025-03-11 21:04:25', 0, 19);
INSERT INTO `payment` (`id`, `user_id`, `order_number`, `payment_type`, `payment_method`, `amount`, `status`, `transaction_id`, `pay_time`, `remark`, `created_at`, `updated_at`, `deleted`, `record_id`) VALUES (33, 8, '1741698293366b3fb67e4', 0, 3, 10.00, 1, 'TX1741698296293713', '2025-03-11 21:04:56', '停车费支付-粤B123455', '2025-03-11 21:04:53', '2025-03-11 21:04:56', 0, 8);
INSERT INTO `payment` (`id`, `user_id`, `order_number`, `payment_type`, `payment_method`, `amount`, `status`, `transaction_id`, `pay_time`, `remark`, `created_at`, `updated_at`, `deleted`, `record_id`) VALUES (34, 8, '1741699186158e9b6c9f4', 1, 3, 10.00, 1, 'TX1741699193948481', '2025-03-11 21:19:54', '预约费支付-A-002', '2025-03-11 21:19:46', '2025-03-11 21:19:54', 0, 20);
INSERT INTO `payment` (`id`, `user_id`, `order_number`, `payment_type`, `payment_method`, `amount`, `status`, `transaction_id`, `pay_time`, `remark`, `created_at`, `updated_at`, `deleted`, `record_id`) VALUES (35, 8, '17416992127927a6af68f', 0, 3, 10.00, 1, 'TX1741699214916667', '2025-03-11 21:20:15', '停车费支付-粤B123455', '2025-03-11 21:20:13', '2025-03-11 21:20:15', 0, 9);
INSERT INTO `payment` (`id`, `user_id`, `order_number`, `payment_type`, `payment_method`, `amount`, `status`, `transaction_id`, `pay_time`, `remark`, `created_at`, `updated_at`, `deleted`, `record_id`) VALUES (36, 8, '174169926823403717bfd', 1, 3, 10.00, 1, 'TX1741699270681262', '2025-03-11 21:21:11', '预约费支付-A-002', '2025-03-11 21:21:08', '2025-03-11 21:21:11', 0, 21);
INSERT INTO `payment` (`id`, `user_id`, `order_number`, `payment_type`, `payment_method`, `amount`, `status`, `transaction_id`, `pay_time`, `remark`, `created_at`, `updated_at`, `deleted`, `record_id`) VALUES (37, 8, '17416992923633d8567e8', 0, 3, 10.00, 1, 'TX1741699294981964', '2025-03-11 21:21:35', '停车费支付-粤B123455', '2025-03-11 21:21:32', '2025-03-11 21:21:35', 0, 10);
COMMIT;

-- ----------------------------
-- Table structure for reservation
-- ----------------------------
DROP TABLE IF EXISTS `reservation`;
CREATE TABLE `reservation` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` int NOT NULL COMMENT '用户ID',
  `vehicle_id` int NOT NULL COMMENT '车辆ID',
  `parking_space_id` int NOT NULL COMMENT '车位ID',
  `start_time` datetime NOT NULL COMMENT '预约开始时间',
  `end_time` datetime NOT NULL COMMENT '预约结束时间',
  `status` tinyint DEFAULT '0' COMMENT '状态（0-待审核，1-已确认，2-已使用，3-已取消，4-已拒绝）',
  `fee` decimal(10,2) DEFAULT '0.00' COMMENT '预约费用',
  `is_paid` tinyint DEFAULT '0' COMMENT '是否已支付（0-未支付，1-已支付）',
  `payment_id` int DEFAULT NULL COMMENT '支付记录ID',
  `remark` text COMMENT '备注信息',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `vehicle_id` (`vehicle_id`),
  KEY `parking_space_id` (`parking_space_id`),
  CONSTRAINT `reservation_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE,
  CONSTRAINT `reservation_ibfk_2` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`id`) ON DELETE CASCADE,
  CONSTRAINT `reservation_ibfk_3` FOREIGN KEY (`parking_space_id`) REFERENCES `parking_space` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='预约记录表';

-- ----------------------------
-- Records of reservation
-- ----------------------------
BEGIN;
INSERT INTO `reservation` (`id`, `user_id`, `vehicle_id`, `parking_space_id`, `start_time`, `end_time`, `status`, `fee`, `is_paid`, `payment_id`, `remark`, `created_at`, `updated_at`, `deleted`) VALUES (19, 8, 1, 93, '2025-03-12 08:00:00', '2025-03-12 10:00:00', 2, 10.00, 1, 32, '', '2025-03-11 21:04:14', '2025-03-11 21:04:21', 0);
INSERT INTO `reservation` (`id`, `user_id`, `vehicle_id`, `parking_space_id`, `start_time`, `end_time`, `status`, `fee`, `is_paid`, `payment_id`, `remark`, `created_at`, `updated_at`, `deleted`) VALUES (20, 8, 1, 94, '2025-03-12 08:00:00', '2025-03-12 10:00:00', 2, 10.00, 1, 34, '', '2025-03-11 21:19:38', '2025-03-11 21:19:44', 0);
INSERT INTO `reservation` (`id`, `user_id`, `vehicle_id`, `parking_space_id`, `start_time`, `end_time`, `status`, `fee`, `is_paid`, `payment_id`, `remark`, `created_at`, `updated_at`, `deleted`) VALUES (21, 8, 1, 94, '2025-03-12 12:00:00', '2025-03-12 14:00:00', 2, 10.00, 1, 36, '', '2025-03-11 21:21:01', '2025-03-11 21:21:06', 0);
COMMIT;

-- ----------------------------
-- Table structure for system_config
-- ----------------------------
DROP TABLE IF EXISTS `system_config`;
CREATE TABLE `system_config` (
  `id` int NOT NULL AUTO_INCREMENT,
  `system_name` varchar(100) NOT NULL COMMENT '系统名称',
  `contact_phone` varchar(20) NOT NULL COMMENT '平台联系电话',
  `open_time` time DEFAULT '00:00:00' COMMENT '营业开始时间',
  `close_time` time DEFAULT '23:59:59' COMMENT '营业结束时间',
  `recognition_time` int DEFAULT '5' COMMENT '车牌识别等待时间(秒)',
  `reservation_valid_time` int DEFAULT '15' COMMENT '预约有效期(分钟)',
  `default_password` varchar(32) NOT NULL COMMENT '系统默认密码',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统配置表';

-- ----------------------------
-- Records of system_config
-- ----------------------------
BEGIN;
INSERT INTO `system_config` (`id`, `system_name`, `contact_phone`, `open_time`, `close_time`, `recognition_time`, `reservation_valid_time`, `default_password`, `created_at`, `updated_at`) VALUES (1, '智慧停车场管理系统', '13800138000', '00:00:00', '23:59:59', 5, 15, 'e10adc3949ba59abbe56e057f20f883e', '2025-03-11 16:45:37', '2025-03-11 16:45:37');
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `username` varchar(50) NOT NULL COMMENT '用户名',
  `password` varchar(255) NOT NULL COMMENT '密码',
  `real_name` varchar(50) DEFAULT NULL COMMENT '真实姓名',
  `phone` varchar(20) DEFAULT NULL COMMENT '手机号码',
  `email` varchar(100) DEFAULT NULL COMMENT '电子邮箱',
  `avatar` varchar(255) DEFAULT NULL COMMENT '头像URL',
  `role` tinyint DEFAULT '0' COMMENT '角色（0-普通用户，1-管理员）',
  `status` tinyint DEFAULT '1' COMMENT '状态（0-禁用，1-启用）',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `last_login` datetime DEFAULT NULL COMMENT '最后登录时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  `balance` decimal(10,2) DEFAULT '0.00' COMMENT '账户余额',
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户表';

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` (`id`, `username`, `password`, `real_name`, `phone`, `email`, `avatar`, `role`, `status`, `created_at`, `updated_at`, `last_login`, `deleted`, `balance`) VALUES (7, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '15126251889', '2452143632@qq.com', '', 1, 1, '2025-03-10 20:27:04', '2025-03-11 21:24:51', '2025-03-11 21:24:51', 0, 0.00);
INSERT INTO `user` (`id`, `username`, `password`, `real_name`, `phone`, `email`, `avatar`, `role`, `status`, `created_at`, `updated_at`, `last_login`, `deleted`, `balance`) VALUES (8, 'user', 'e10adc3949ba59abbe56e057f20f883e', '普通用户', '15143214321', '123456789@qq.com', '', 0, 1, '2025-03-10 20:28:33', '2025-03-11 21:21:35', '2025-03-11 19:50:22', 0, 475.00);
INSERT INTO `user` (`id`, `username`, `password`, `real_name`, `phone`, `email`, `avatar`, `role`, `status`, `created_at`, `updated_at`, `last_login`, `deleted`, `balance`) VALUES (10, 'test123', 'e10adc3949ba59abbe56e057f20f883e', '测试用户', '15126251888', '24521436@qq.com', NULL, 0, 1, '2025-03-11 00:45:45', '2025-03-11 00:45:45', NULL, 0, 0.00);
COMMIT;

-- ----------------------------
-- Table structure for user_audit
-- ----------------------------
DROP TABLE IF EXISTS `user_audit`;
CREATE TABLE `user_audit` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '审核ID',
  `user_id` int NOT NULL COMMENT '用户ID',
  `audit_type` tinyint NOT NULL COMMENT '审核类型：1-用户注册，2-车辆审核，3-其他',
  `related_id` int DEFAULT NULL COMMENT '关联ID',
  `related_info` varchar(255) DEFAULT NULL COMMENT '关联信息',
  `status` tinyint NOT NULL DEFAULT '0' COMMENT '审核状态：0-待审核，1-已通过，2-已拒绝',
  `remark` varchar(500) DEFAULT NULL COMMENT '审核备注',
  `auditor_id` int DEFAULT NULL COMMENT '审核人ID',
  `audit_time` datetime DEFAULT NULL COMMENT '审核时间',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除：0-否，1-是',
  PRIMARY KEY (`id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_status` (`status`),
  KEY `idx_audit_type` (`audit_type`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户审核表';

-- ----------------------------
-- Records of user_audit
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for vehicle
-- ----------------------------
DROP TABLE IF EXISTS `vehicle`;
CREATE TABLE `vehicle` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` int NOT NULL COMMENT '用户ID',
  `plate_number` varchar(20) NOT NULL COMMENT '车牌号码',
  `vehicle_type` varchar(50) DEFAULT NULL COMMENT '车辆类型',
  `vehicle_color` varchar(20) DEFAULT NULL COMMENT '车辆颜色',
  `vehicle_brand` varchar(50) DEFAULT NULL COMMENT '车辆品牌',
  `vehicle_model` varchar(50) DEFAULT NULL COMMENT '车辆型号',
  `is_default` tinyint DEFAULT '0' COMMENT '是否默认车辆（0-否，1-是）',
  `status` tinyint DEFAULT '0' COMMENT '状态（0-待审核，1-已审核，2-拒绝）',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint DEFAULT '0' COMMENT '是否删除（0-未删除，1-已删除）',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车辆表';

-- ----------------------------
-- Records of vehicle
-- ----------------------------
BEGIN;
INSERT INTO `vehicle` (`id`, `user_id`, `plate_number`, `vehicle_type`, `vehicle_color`, `vehicle_brand`, `vehicle_model`, `is_default`, `status`, `created_at`, `updated_at`, `deleted`) VALUES (1, 8, '粤B123455', '小型轿车', '黑色', '宝马', 'X5', 1, 1, '2025-03-10 21:06:09', '2025-03-10 21:06:09', 0);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
